package com.wzh.design.newDesignPattern.observerPattern;

import java.util.ArrayList;
import java.util.List;

/**
 * @description:
 * @author: WZH
 * @time: 2022/3/23 13:50
 */
public class Student {

    private List<Observer> observers = new ArrayList<>();

    private int state;

    public int getState() {
        return state;
    }

    public void setState(int state) {
        this.state = state;
        notifyObservers();
    }

    public void attach(Observer observer){
        observers.add(observer);
    }

    public  void notifyObservers(){
        for (Observer observer : observers) {
            observer.update();
        }
    }


}
